package com.threadmethod.yieId;

import sun.print.SunMinMaxPage;

/**
 * @PackageName:com.threadmethod.yieId
 * @ClassName:SubThread05
 * @Description:
 * @Author: zhangxiaoyu
 * @date 2020/11/19 17:06
 */
public class SubThread05 extends Thread{

    @Override
    public void run() {

        long begin = System.currentTimeMillis();

        long sun = 0;

        for(int i =1;i<=1000000;i++){
            sun +=i;
            //线程让步，放弃cpu的执行权
            Thread.yield();
        }


        long end =System.currentTimeMillis();

        System.out.println("用时："+(end - begin));
    }
}
